package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.dto.HouseListRespDTO;
import com.ruoyi.common.dto.HouseQueryReqDTO;
import com.ruoyi.domain.dto.req.ShopInsertReqDTO;
import com.ruoyi.service.OfficeBuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description:
 * @projectName: zf_master
 * @package: com.ruoyi.domain.dto.req
 * @className: OfficeBuildingController
 * @author: gyh
 * @date: 2024/9/14 15:38
 * @version: 1.0
 */
@RestController
@RequestMapping("/office/office")
public class OfficeBuildingController extends BaseController {
    @Autowired
    private OfficeBuildingService officeBuildingService;

    /**
     * @param shopInsertReqDTO
     * @return * @return: com.ruoyi.common.core.domain.R
     * @description 新增商业用房
     * @author gyh
     * @date 2024/9/17 14:59
     */
    @PostMapping("/insert")
    public R insertOfficeBuilding(@RequestBody ShopInsertReqDTO shopInsertReqDTO) {
        return officeBuildingService.insertOfficeBuilding(shopInsertReqDTO);
    }

    /**
     * @param houseQueryReqDTO
     * @return * @return: com.ruoyi.common.core.page.TableDataInfo
     * @description 分页列表
     * @author gyh
     * @date 2024/9/17 23:21
     */
    @GetMapping("/officePage")
    public TableDataInfo officeList(HouseQueryReqDTO houseQueryReqDTO) {
        System.out.println("123123123131");
        startPage();
        //分页查询所有商业用房
        List<HouseListRespDTO> shopListRespDTOS = officeBuildingService.officeList(houseQueryReqDTO);
        return getDataTable(shopListRespDTOS);
    }

    /**
     * @param id
     * @return * @return: com.ruoyi.common.core.domain.R
     * @description 删除商业房源
     * @author gyh
     * @date 2024/9/17 23:21
     */
    @PostMapping("/delById/{id}")
    public AjaxResult delById(@PathVariable String id) {
        return toAjax(officeBuildingService.delById(id));
    }

}
